import React, { PureComponent } from 'react'
import { connect } from 'react-redux'
import { changeBanners } from '../store/actionCreators'

export class Catagory extends PureComponent {

  componentDidMount() {
    this.props.fetchBannerList() // 调用action
  }

  render() {
    const { banners } = this.props
    return (
      <div>
        <span>banner:数据</span>
          <ul>
            {
              banners.map((item,index) => <li key={index}>{item.title}</li>)
            }
          </ul>
      </div>
    )
  }
}
const mapStateToProps = (state) => ({
  counter: state.counter,
  banners: state.banners
})
const mapDispatchToProps = (dispatch) => ({
  fetchBannerList: () => dispatch(changeBanners())
})
export default connect(mapStateToProps,mapDispatchToProps)(Catagory)